package com.liuyi.netty.im.server.handle.cluster.impl.dispose;

import com.liuyi.netty.im.commons.codes.data.DataEvent;
import com.liuyi.netty.im.server.handle.cluster.ClusterMessageDispose;
import com.liuyi.netty.im.server.handle.storage.ChannelStorage;
import io.netty.channel.Channel;

import java.util.ArrayList;
import java.util.List;

/**
 * toId 为channelId 的时候处理
 *
 * @author Mr.Fmy
 * @since 2021/12/25
 */
public class ChannelIdClusterMessageDispose implements ClusterMessageDispose {

    @Override
    public List<Channel> dispose(DataEvent data) {
        List<Channel> result = new ArrayList<>();
        String toId = data.getToId();
        if (ChannelStorage.containsChannelId(toId)) {
            result.add(ChannelStorage.get(toId));
        }
        return result;
    }
}
